package com.wg.wuge.tulin.jvm;

import sun.misc.Launcher;

import java.net.URL;
import java.util.Arrays;

/**
 * 各种 class加载文件 ，判断加载器的关系。
 */
public class TestJDKClassLoader {

    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());
        System.out.println(com.sun.crypto.provider.DESKeyFactory.class.getClassLoader());
        System.out.println(TestJDKClassLoader.class.getClassLoader().getClass().getName());
        System.out.println();
        ClassLoader appClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader bootstrapClassLoader = extClassLoader.getParent();
        System.out.println("appClassLoader is " + appClassLoader);
        System.out.println("extClassLoader is " + extClassLoader);
        System.out.println("bootstrapClassLoader is " + bootstrapClassLoader);
        System.out.println();
        System.out.println("bootstrapLoader加载以下文件：");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        Arrays.stream(urLs).forEach(System.out::println);
        System.out.println();
        System.out.println("extClassloader加载以下文件：");
        System.out.println(System.getProperties().get("java.ext.dirs"));
        System.out.println();
        System.out.println("appClassloader加载以下文件：");
        System.out.println(System.getProperties().get("java.class.path"));

    }
    public void print() {
        System.out.println("wuge test it");
    }
}
